home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / gcc / ixemlsrc.lha / ixemul / library / ix_get_vars2.c < prev    next >
C/C++ Source or Header  |  1996-03-28  |  3KB  |  109 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  ix_get_vars2.c,v 1.1.1.1 1994/04/04 04:30:55 amiga Exp
  20.  *
  21.  *  ix_get_vars2.c,v
  22.  * Revision 1.1.1.1  1994/04/04  04:30:55  amiga
  23.  * Initial CVS check in.
  24.  *
  25.  *  Revision 1.4  1992/08/09  20:49:16  amiga
  26.  *  add cast
  27.  *
  28.  *  Revision 1.3  1992/07/04  19:14:44  mwild
  29.  *  add new variable, environ-in, primarly support for fork-emulation in ksh
  30.  *
  31.  * Revision 1.2  1992/05/20  01:32:00  mwild
  32.  * do atexit(_cleanup) here, ix_open is the wrong place
  33.  *
  34.  * Revision 1.1  1992/05/14  19:55:40  mwild
  35.  * Initial revision
  36.  *
  37.  */
  38.  
  39. #define KERNEL
  40. #include "ixemul.h"
  41. #include "kprintf.h"
  42.  
  43. #include <stdio.h>
  44. #include <stdlib.h>
  45.  
  46. extern char _ctype_[];
  47. extern int sys_nerr;
  48. extern void _cleanup();
  49.  
  50. /* too bad this is necessary, but the old function didn't know how to tell
  51.  * how many values to fill out, making later extensions impossible without
  52.  * breaking old executables. This one uses an explicit counter for this.
  53.  */
  54.  
  55. void
  56. ix_get_vars2 (int argc, char **ctype, int *_sys_nerr, 
  57.           struct Library **sysbase, struct Library **dosbase,
  58.           FILE ***fpp, char ***environ_out, char ***environ_in,
  59.           int *real_errno)
  60. {
  61.   switch (argc)
  62.     {
  63.     default:
  64.     case 8:
  65.       /* Needed in pdksh: after the ix_resident call the child needs to
  66.          tell ixemul.library what the new address of the errno variable is. */
  67.       if (real_errno)
  68.     {
  69.       u.u_errno = real_errno;
  70.           if (u.u_ixnetbase)
  71.         NET_set_errno(real_errno);
  72.     }
  73.  
  74.     case 7:
  75.       /* a `bit' kludgy.. */
  76.       if (environ_in) *environ_in = *u.u_environ;
  77.  
  78.     case 6:
  79.       if (environ_out) u.u_environ = environ_out;
  80.  
  81.     case 5:
  82.       if (fpp)
  83.         {
  84.       __init_stdinouterr ();
  85.           *fpp = (FILE **) &u.u_sF[0];
  86.       /* make sure all stdio buffers are flushed on exit() */
  87.       atexit (_cleanup);
  88.         }
  89.  
  90.     case 4:
  91.       if (dosbase) *dosbase = (struct Library *)DOSBase;
  92.       
  93.     case 3:
  94.       if (sysbase) *sysbase =  (struct Library *)SysBase;
  95.       
  96.     case 2:
  97.       if (_sys_nerr) *_sys_nerr = sys_nerr;
  98.       
  99.     case 1:
  100.       if (ctype) *ctype = _ctype_;
  101.     
  102.     case 0:
  103.       break;
  104.     }
  105.    
  106.   /* now that system start is over, free the tracer */
  107.   u.u_trace_flags = 0;
  108. }
  109.